﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace Happy.Web.Mvc.Security
{
    /// <summary>
    /// 每次请求开始都为 HttpContext.User 提供一个值。
    /// </summary>
    public sealed class HappyAuthorizationFilter : IAuthorizationFilter
    {
        /// <summary>
        /// 开始认证。
        /// </summary>
        public void OnAuthorization(AuthorizationContext filterContext)
        {
            filterContext.HttpContext.User = HappyAuthorization.GetPrincipal();
        }
    }
}
